<template>
  <div class="myGoodsCard">
    <div @click="$emit('productHandle')">

      <div class="img"><el-image :src="img" lazy></el-image></div>
      <p class="name ellipsis-2">{{ name }}</p>
      <p class="desc">{{ desc }}</p>
      <p class="price">￥{{ price }}</p>
    </div>
    <div class="extra">
      <router-link to="/">
        <p>找相似</p>
        <p>发现更多宝贝 ></p>
      </router-link>
    </div>
  </div>
</template>
<script>
import { ref, reactive, toRefs, computed } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useStore } from "vuex";
export default {
  props: {
    img: {
      type: String,
      default: "",
    },
    name: {
      type: String,
      default: "",
    },
    desc: {
      type: String,
      default: "",
    },
    price: {
      type: String,
      default: "",
    },

  },
  name: "myGoodsCard",
  setup(props, ctx) {
    /* 定义仓库 */
    const store = useStore();
    /* 定义路由传参 */
    const router = useRouter();
    /* 定义路由收参 */
    const route = useRoute();
    /* 定义总数据存放地址 */
    const data = reactive({});
    return { ...toRefs(data) };
  },
  components: {},
};
</script>
<style lang="scss" scoped>
/* 如果不想样式污染  就加个scoped */
.myGoodsCard {
  width: 240px;
  height: 300px;
  padding: 10px 30px;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  transition: all 0.5s;
  cursor: pointer;
  margin-bottom: 10px;
  &:hover {
    border: 1px solid var(--color);
    .extra {
      transform: translateY(0);
    }
  }
  .img {
    text-align: center;
  }
  .el-image {
    width: 160px;
    height: 160px;
  }
  .name,
  .desc {
    margin-top: 6px;
  }
  .desc {
    color: #666;
    height: 22px;
    display: -webkit-box;
    overflow: hidden;
    white-space: normal !important;
    text-overflow: ellipsis;
    word-wrap: break-word;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
  .price {
    margin-top: 10px;
    font-size: 20px;
    color: #cf4444;
  }
  .extra {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--color);
    height: 86px;
    text-align: center;
    transform: translateY(100%);
    transition: all 0.5s;
    a {
      color: #fff;
      p:first-child {
        //   margin: ;
        font-size: 18px;
        border-bottom: 1px solid #fff;
        line-height: 40px;
        margin-top: 5px;
      }
      p {
        display: block;
        color: #fff;
        width: 120px;
        margin: 0 auto;
        line-height: 30px;
      }
      p:last-child {
        font-size: 14px;
      }
    }
  }
}
</style>